package com.ruoyi.redtea.dualprevent.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.redtea.dualprevent.service.TrainAssessAnalyseUnitService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: RuoYi-Cloud
 * @ClassName TrainUnitAssessContriller
 * @author: LGP
 * @create: 2024-05-15 10:11
 * @description:分析单元评估
 **/
@RestController
@RequestMapping("trainAnaUnitAssess")
public class TrainAnalyseUnitAssessController {

    @Resource
    private TrainAssessAnalyseUnitService trainAssessAnalyseUnitService;
    @GetMapping("list")
    public AjaxResult queryList() {
        return AjaxResult.success(trainAssessAnalyseUnitService.queryAssessList());
    }

    @PutMapping("/updateIdentifyWay/{unitId}/{identifyWay}")
    public AjaxResult updateIdentifyWay(@PathVariable Integer unitId,@PathVariable Integer identifyWay){
        boolean updateIdentifyWay = trainAssessAnalyseUnitService.updateIdentifyWay(unitId,identifyWay);
        if(updateIdentifyWay){
            return AjaxResult.success("风险辨识更新成功");
        }else {
            return AjaxResult.success("风险辨识更新失败");
        }
    }

    @PutMapping("/updateAssessRisk/{unitId}/{riskLv}/{assessWay}")
    public AjaxResult updateAssessRisk(@PathVariable Integer unitId,@PathVariable Integer riskLv,@PathVariable Integer assessWay){
        boolean updateAssessRisk = trainAssessAnalyseUnitService.updateAssessRisk(unitId, riskLv,assessWay);
        if(updateAssessRisk){
            return AjaxResult.success("分析单元评估更新成功");
        }else {
            return AjaxResult.success("分析单元评估更新失败");
        }
    }

}
